// pages/main/others/updateconsult.js
import {consultdetail} from "../../../api/wrd/index"
import {updateconsult} from "../../../api/wrd/index"
Page({
  data: {
    consultInfo:{},
    workercode:'',
    name:'',
    radio: '',
    tel:'',
    QQ:'',
    wx:'',

  },
   //获取顾问详情
   async getconsultdetail(){
    let res=await consultdetail({
      adminId:wx.getStorageSync('adminId')
    })
    this.setData({
      consultInfo:res.dataset
    })
    this.setData({
      workercode:this.data.consultInfo.salesNum,
      name:this.data.consultInfo.salesName,
      radio:this.data.consultInfo.salesSex,
      tel:this.data.consultInfo.tel,
      QQ:this.data.consultInfo.salesQQ,
      wx:this.data.consultInfo.salesVx
    })
    console.log("123132",this.data.consultInfo);
    console.log("顾问详情",res);
  },
  //员工号
  getworkercode(event){
      this.setData({
        workercode:event.detail.value
      })
  },
  //姓名
  getname(event){
    this.setData({
      name:event.detail.value
    })
},
//手机号码
gettel(event){
  this.setData({
    tel:event.detail.value
  })
},
//QQ
getQQ(event){
  this.setData({
    QQ:event.detail.value
  })
},
//WX
getwx(event){
  this.setData({
    wx:event.detail.value
  })
},
//性别
onChange(event) {
  console.log(event);
  this.setData({
    radio: event.detail,
  });
},
//确认提交
async goupdate(){
  let res= await updateconsult({
    userName:this.data.name,
    sex:this.data.radio,
    tel:this.data.tel,
    Vx:this.data.wx,
    QQ:this.data.QQ,
    adminId:wx.getStorageSync('adminId')
  })
  if(res.code==200){
    wx.showToast({
      title: '修改成功',
      icon:'success'
    })
    setTimeout(() => {
      wx.navigateTo({
        url: '../others/consultantdetail',
      })
    }, 800);
  }
  console.log(res);
},
  onLoad(options) {
    this.getconsultdetail()
  },
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})